//package tech.aistar.filter;
//
//
//import tech.aistar.entity.User;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//
////@WebFilter(filterName="druidWebStatFilter",urlPatterns="/client/*",
//////        initParams={
//////                @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")//忽略资源
////        }
////)
////public class DruidStatFilter extends WebStatFilter {
////}
////@WebFilter(urlPatterns = "/address/*")
//@WebFilter(urlPatterns = "/collection/*")
//public class DruidStatFilter implements Filter {
//        @Override
//        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//                //需要进行一个转换
//                HttpServletRequest req = (HttpServletRequest) servletRequest;
//                HttpServletResponse resp = (HttpServletResponse) servletResponse;
//
//                System.out.println("检查用户是否登录的过滤器...");
//
//                //判断用户是否登录
//                User user = (User) req.getSession().getAttribute("user");
//                if(null == user){
//                        //重定向到登录界面
//                        resp.sendRedirect(req.getContextPath()+"/client/loginView");
//                }else{
//                        //此代码行以上的代码是进入目标servlet之前执行的
//                        //决定是否放行
//                        filterChain.doFilter(req,resp);
//                }
//        }
//}
